/**
 * 
 *  @project Air Traff Monitor
 * 
 *  @author M.Emre ATASEVER <m.emre.atas@gmail.com>
 *  @author M.Burak ALKAN <mburakalkan@gmail.com>
 *  @author H.Burak KARAMIK <bkaramik@gmail.com>
 *
 *	`Air Traffic Monitor' is distributed in the hope that it will be useful,
 *	but WITHOUT ANY WARRANTY; without even the implied warranty of
 *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *	GNU General Public License for more details.
 *
 *	You should have received a copy of the GNU General Public License
 *	along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef KISVIEW_H
#define KISVIEW_H

#include <QTreeWidget>
#include <QMenu>
#include "kismodel.h"
#include "kisfilter.h"

class QKismetAction;

class QKismetTreeView : public QTreeView
{
	Q_OBJECT

public:
	QKismetTreeView(QAbstractItemModel *model);
	~QKismetTreeView();
	QMenu *headMenu;
	QMenu* appendMenu(QString title,const QStringList *titles,const QStringList *commands,QMenu *menu, int off,int cnt);
	QList<QAction*> menuActions();

	void WriteSettings(QString &secname);
	void RestoreSettings(QString &secname,QList<QAction*> &acts, QList<QVariant> initCols = QList<QVariant>() <<0<<1<<2);
	
	QList<QVariant> InitialColumns();
	QList<QKismetAction*> actions;
	QList<QMenu*> menus;

	QMenu *popupMenu;
	QAction *aclear;
	KismetSortFilterProxy proxy;

public slots:
	void showPopupMenu(const QPoint& pos);
	void showHeadMenu(const QPoint& pos);
	void toggleColumn();
	void cleared();
	void saveContents();
	void copyContents();
signals:
	void setOption(QString opt, bool enable);
private:
	void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected);
	void rowsInserted(const QModelIndex& parent,int start, int end);
	void getIndexData(QModelIndex ix, bool selonly, QList<int>* cols, QString& out);
	void getIndexData(QModelIndex ix, bool selonly, QList<int>* cols, QTextStream& out);
	QAction *asave,*acopy,*asel;

	KismetItemModel *kmod;
};

class QKismetAction : public QAction
{
	Q_OBJECT
public:
	QKismetAction(const QString& pname, const QString& text,int ix,QObject *parent);
	
	QString propName;
	int i;
};
#endif
